Skip to content

Conversation

@GeertJohan
Copy link
Member

Fixes #37

@GeertJohan GeertJohan force-pushed the configurable-output-files branch 2 times, most recently from 7f0f622 to f0f8faa Compare January 15, 2026 08:29
@@ -1,10 +0,0 @@
-- ** Database generated with pgModeler (PostgreSQL Database Modeler).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file still exists but its empty because there are no diffs.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes generated output files (SQL, PNG, SVG) optional and configurable through the trek.yaml configuration file, addressing issue #37. When output types are defined in the config, files are generated at customizable or default paths. The initial migration logic has also been updated to generate diffs instead of directly copying SQL files.

Changes:

  • Added output configuration section to control which file types (SQL, PNG, SVG) are generated
  • Refactored SQL export to use a temporary directory, only copying to output path if enabled
  • Added SVG export capability and made PNG export conditional

Reviewed changes

Copilot reviewed 8 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/configuration/config.go Added Output, OutputFile types and GetOutputPath() method to support optional output files
internal/templates/trek.yaml.tmpl Updated template to include empty output section for SQL and SVG by default
internal/pgmodeler.go Renamed functions (consistent casing) and added PgmodelerExportSVG() function
cmd/generate.go Modified generation logic to conditionally create output files and use temp directory for SQL
tests/output/trek.yaml, example/trek.yaml Added output configuration sections
tests/output/*.gen.{sql,svg}, example/*.gen.{sql,svg} New generated output files
tests/output/migrations/001_init.up.sql, example/migrations/001_init.up.sql Updated migration files with different content structure

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- name: {{.}}{{end}}
output:
sql: {}
svg: {}
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trek.yaml template now includes output configuration for sql and svg but not png. Consider documenting this behavior or adding a comment in the template to explain that png can also be configured if needed. This would help users understand all available output options.

Suggested change
svg: {}
svg: {}
# Note: PNG output can also be configured here if needed, for example:
# png: {}

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +490 to +520
sqlContent, err = os.ReadFile(tmpSQLPath)
if err != nil {
return "", fmt.Errorf("failed to read sql file: %w", err)
}
err = os.WriteFile(filepath.Join(wd, sqlPath), sqlContent, 0o644) //nolint:gosec
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not copy the file without read/write?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How? There is no os.Copy right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

io.Copy, but I guess in doesn't really matter given the amount of data we're handling here.

Comment on lines +7 to +8
sql: {}
svg: {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the example it would be nice to have one with an explicit path.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but the example is generated via trek init which doesn't have env vars to set these.. I don't think adding env vars there makes sense. I think instead we should improve documentation in general. And/or maybe the example dir shouldn't be generated?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah maybe get rid of the example, since it's empty anyway it doesn't have that much value and it isn't even useful as a starting point, since we have trek init.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets pick that up in a separate story/PR; to improve docs in general.

Copy link
Collaborator

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please regenerate the tests

@GeertJohan GeertJohan force-pushed the configurable-output-files branch from eaa31b8 to 98fc879 Compare January 17, 2026 12:09
@GeertJohan
Copy link
Member Author

Rebased. Also re-ran tests but it didn't make any changes.

@provokateurin
Copy link
Collaborator

Also re-ran tests but it didn't make any changes.

Shouldn't the config file change after?

@GeertJohan
Copy link
Member Author

The config file already has the new outputs right?

@GeertJohan GeertJohan merged commit 3deb338 into main Jan 17, 2026
2 checks passed
@GeertJohan GeertJohan deleted the configurable-output-files branch January 17, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make generate artifacts configurable

2 participants